#include <cstdlib>
#include <iostream>
#include <fstream>
#include "grafo.h"
#include "lista.h"
#include "ListaRefinada.h"
#include "TestCordalidad.h"
#include "CliqueTree.h"


using namespace std;







int main(int argc, char *argv[])
{
    ifstream is;
    if(argc==1){
        cout << "No se ingreso el grafo. Modo de uso: LexBFS grafo.txt" << endl;
        return 0;
    }




	is.open(argv[1]);

	if(!is){
	    cout << "El archivo no existe." << endl;
        return 0;
    }



		int n = 0;
		is >> n ;

        Grafo g(n, is);
		cout << g << endl;

		vector<int> v1 = g.lexBFS();



		cout<<"Orden eliminacion LexBFS: [";
		for(int i=v1.size()-1; i >= 0 ; i--){
			cout << v1[i] ;
			if(i>0){cout << " ";}
		}
		cout << "]" << endl;

		vector<int> v2 = g.co_lexBFS();

		cout<<"Orden eliminacion Co-LexBFS: [";
		for(int i=v2.size()-1; i >= 0 ; i--){
			cout << v2[i] ;
			if(i>0){cout << " ";}
		}
		cout << "]" << endl;


  cout << "TESTEANDO GRAFO..." << endl <<endl;
  TestCordalidad tc = TestCordalidad(g, v1, false);
  if (tc.test()){
  	cout << "********El grafo es cordal.********" << endl;
  	CliqueTree ct = CliqueTree(g, g.cant_nodos(), tc.rns, tc.hijos, list<int>(),v1);
    ct.armarArbolDeCliques();
  }
  else{
    cout << "********El grafo no es cordal.********" << endl;
  }


  cout << "TESTEANDO COMPLEMENTO..." << endl << endl;
  TestCordalidad tc2 = TestCordalidad(g, v2, true);
  if (tc2.test()){
  	cout << "********El complemento es cordal.********" << endl;
  	CliqueTree ct = CliqueTree(g, g.cant_nodos(), tc2.rns, tc2.hijos, tc2.co_padres(v2),v2);
    ct.armarCoArbolDeCliques();

  }
  else{
    cout << "********El complemento no es cordal.********" << endl;
  }



    return EXIT_SUCCESS;
}
